package com.p2p.quartz;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.p2p.common.utils.DateUtil;
import com.p2p.user.po.User;
import com.p2p.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class IntervalHistoryParseJob {


    @Autowired
    private UserService userService;

    // 定时任务
    public void start() throws IOException {
        String date = DateUtil.date2Str(new Date(System.currentTimeMillis() - 1000 * 3600 * 24), DateUtil.FORMAT_DATE);
        String month = DateUtil.date2Str(new Date(System.currentTimeMillis() - 1000 * 3600 * 24),
                DateUtil.FORMAT_MONTH);
        EntityWrapper<User> userWrapper = new EntityWrapper<User>();
        userWrapper.where("LEFT(create_time,10)= {0}", date);
        List<User> userList = userService.selectList(userWrapper);

        Long userCount = (long) userService.selectCount(new EntityWrapper<User>());


    }

    public Map str2Map(String str) {
        Map<String, String> map = new HashMap<String, String>();
        String[] arr = str.split(";");
        for (String s : arr) {
            String[] value = s.split(":");
            map.put(value[0].replace(" ", ""), value[1].replace(" ", ""));
        }
        return map;
    }


}
